<?php
// 配置类型模型
class ContentModel extends Model {
	
	
	//获得所有内容（分页）
	public function getAllContentPageByCat($catId,$pageSize){
		  import("ORG.Util.Page"); // 导入分页类 
		  $count = $this->field('id')->where('cat='.$catId)->count();
		  $Page  = new Page($count,$pageSize);
		  $temp['page'] =  $Page->show();
		  $temp['list'] =  $this->field('id,title,ctime,uname,info,status,model,img')->where('cat='.$catId)->order('tc.ctime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		  
		  return $temp;
	}
	
	//获得所有通过审核的内容(分页)
	
	public function getContentPageByCat($catId,$pageSize){
		
			import("ORG.Util.Page"); // 导入分页类 
		  $count = $this->field('id')->where('cat='.$catId.' and status=1')->count();
		  $Page  = new Page($count,$pageSize);
		  $temp['page'] =  $Page->show();
		  $temp['list'] =  $this->field('id,title,ctime,uname,info,status,model,img,isimg,istop,isrecom')->where('cat='.$catId.' and status=1')->order('tc.ctime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		  
		  return $temp;
	}
	
	//根据栏目获得类容列表
	
	public function getContentByCat($cat,$num=20){
		
		 $list = $this->field('id,title,ctime,uname,info,status,model,img,isimg,istop,isrecom')->where('cat='.$catId.' and status=1')->order('tc.ctime desc')->limit($num)->select();
		 
		 return $list;
		
	}
	
	//获得置顶的内容
	public function getTopContent($cat,$num=1){
		 $list = $this->field('id,title,ctime,uname,info,status,model,img,isimg')->where('cat='.$catId.' and status=1 and istop=1')->order('tc.ctime desc')->limit($num)->select();
		 
		 return $list;
		 
	}
	
	//获得推荐的内容
	public function getRecomeContent($cat,$num=20){
		 $list = $this->field('id,title,ctime,uname,info,status,model,img,isimg')->where('cat='.$catId.' and status=1 and isrecom=1')->order('tc.ctime desc')->limit($num)->select();
		 
		 return $list;
	}
	
	public function getNewContent($num=20){
		$list = $this->field('id,title,ctime,uname,info,status,model,img,isimg')->where('cat='.$catId.' and status=1 and isrecom=1')->order('tc.ctime desc')->limit($num)->select();		 
		return $list;
	}
}
?>